exports.main = async (event,context) => {	
	//接收前端传输过来的base64数据
	let imageBase = event.body;		
	const { randomUUID } = require('crypto');
	
	// 生成一个版本4的UUID
	console.log(randomUUID());
	//去除编码头
	let base64 = imageBase.split(",")[1];
	//获取文件后缀名
	let suffix = imageBase.split('/')[1].split(';')[0];
	   
	let result = await uniCloud.uploadFile({
		//保存到云端的文件名
		cloudPath: randomUUID() + "." + suffix,
		//base64转buffer（阿里云支持buffer和绝对路径）		
		fileContent: Buffer.from(base64,'base64'),
		success(res){
			//阿里云直接返回文件ID就是下载地址
			return {code:0,msg:'上传成功',data:result}
		},
		fail(err) {
			reject(new Error(err.errMsg))
		}
	});			
	return {code:0,msg:'上传成功',data:result}
	
};
